<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html>
<head>
    <title>Session & Cookie Demo</title>
</head>
<body>
<h1>Session和Cookie演示</h1>

<h3>Session数据：</h3>
<p>访问次数：${sessionData}</p>

<h3>Cookie数据：</h3>
<%
    Cookie[] cookies = request.getCookies();
    if (cookies != null) {
        for (Cookie cookie : cookies) {
            if ("lastVisit".equals(cookie.getName())) {
                java.util.Date lastVisit = new java.util.Date(Long.parseLong(cookie.getValue()));
%>
<p>最后访问时间：<%= lastVisit %></p>
<%
            }
        }
    }
%>

<form action="session-cookie-demo" method="post">
    <input type="submit" value="增加访问次数">
</form>

<a href="index.jsp">返回首页</a>
</body>
</html>
